<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php echo $this->_var['meta']; ?>
<link type="text/css" rel="stylesheet" href="<?php echo $this->_var['css_path']; ?>/global.css" />
<link type="text/css" rel="stylesheet" href="<?php echo $this->_var['css_path']; ?>/style.css" />
</head><body>
 
<?php echo $this->fetch('top.html'); ?>
<?php echo $this->fetch('header.html'); ?> 

<div id="main">
  <div class="q2a_detail_left">
    <div class="know_title">
      <div class="know_title_pic"> <img src="<?php echo $this->_var['data']['avatar_path']; ?>"/> </div>
      <div class="know_title_detail">
        <p id="q2a_name"><?php echo $this->_var['data']['name']; ?></p>
        <p><a href="#"><?php echo $this->_var['data']['username']; ?></a><span>&nbsp;发表于&nbsp;<?php echo Date::floortime($this->_var['data']['timeformat'],2); ?>,&nbsp;<?php echo $this->_var['data']['answer_count']; ?>人回/<?php echo $this->_var['data']['view_count']; ?>人浏览</span></p>
      </div>
    </div>
    <div class="know_content_detail">
      <div class="content_detail_list"> <?php echo $this->_var['data']['content']; ?> </div>
      <div class="label">
        <div class="biaoqian">标签：</div>
        <p class="tags_list"> <?php if (count ( $this->_var['data']['tags'] ) > 0): ?>
          <?php $_from = $this->_var['data']['tags']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'tags');if (count($_from)):
    foreach ($_from AS $this->_var['tags']):
?> <a href='<?php echo $this->_var['site_url']; ?>question/tag/<?php echo $this->_var['tags']['id']; ?>' title='<?php echo $this->_var['tags']['name']; ?>'><?php echo $this->_var['tags']['name']; ?></a> <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>    
          <?php endif; ?> </p>
      </div>
  
      
      <div class="yes_no">
        <ul>
          <li id="step"  onclick="add_votes('down')">(<span id="step_num"></span>)</li>
          <li id="support" onclick="add_votes('up')">(<span id="support_num"></span>)</li>
          <li id="star" onclick="collect_q2a(<?php echo $this->_var['data']['id']; ?>)">(<?php echo $this->_var['data']['collects']; ?>)</li>
        </ul>
            <div class="clear"></div>
      </div>
       <p id="msg" style="text-align:center;color:red"></p>
          <div class="clear"></div>
    </div>
    <!--    <div class="answer">
      <p><span>共有<span>3</span>个答案</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">我要回答>></a></p>
    </div>-->
    <div class="other_answer"> <?php $_from = $this->_var['answer_list']['top_answer']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'answer');if (count($_from)):
    foreach ($_from AS $this->_var['answer']):
?>
      <div class="other_answer_list">
        <div class="answer_people"> <img src="<?php echo $this->_var['answer']['avatar_path']; ?>" alt="<?php echo $this->_var['answer']['username']; ?>"/> </div>
        <div class="answer_people_right">
          <p><?php echo $this->_var['answer']['content']; ?></p>
          <p><?php echo $this->_var['answer']['username']; ?><span>回答于&nbsp;&nbsp;&nbsp;<?php echo Date::floortime($this->_var['comment']['add_time'],2); ?></span></p>
          <p style="font-weight:bolder;">- - -共有&nbsp;&nbsp;&nbsp;<?php echo $this->_var['answer']['comments_count']; ?> &nbsp;&nbsp;&nbsp;条评论- - -</p>
          <?php $_from = $this->_var['answer']['comments']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'comment');if (count($_from)):
    foreach ($_from AS $this->_var['comment']):
?>
          <p style=" color:#ff6600;"><img align="absmiddle" user="207467" class="SmallPortrait" title="<?php echo $this->_var['comment']['username']; ?>" alt="<?php echo $this->_var['comment']['username']; ?>" src="<?php echo $this->_var['comment']['avatar_path']; ?>" width="35" height="35"><?php echo $this->_var['comment']['username']; ?> 回复说：<?php echo $this->_var['comment']['content']; ?> <span>时间：<?php echo Date::floortime($this->_var['comment']['add_time'],2); ?></span></p>
          <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
          <div class="votes" style="float: right;"> <span id="answer_message_<?php echo $this->_var['answer']['id']; ?>"></span> <span id="answer_votes_<?php echo $this->_var['answer']['id']; ?>"> <a href="javascript:add_answer_votes('up',<?php echo $this->_var['answer']['id']; ?> )">有帮助</a><em>(<?php echo $this->_var['answer']['up_votes']; ?>)</em>&nbsp;| <a href="javascript:add_answer_votes('down',<?php echo $this->_var['answer']['id']; ?> )">没帮助</a><em>(<?php echo $this->_var['answer']['down_votes']; ?>)</em>&nbsp;| </span> <a href="javascript:void(0);" id="replay_answer_<?php echo $this->_var['answer']['id']; ?>" class="replay_answer" title="<?php echo $this->_var['answer']['id']; ?>">回复</a><em>(<?php echo $this->_var['answer']['comment_count']; ?>)</em>&nbsp;|
            <?php if ($this->_var['data']['user_id'] == $this->_var['user']['id']): ?>
            <?php if (! count ( $this->_var['top_answer'] ) > 0): ?> <span class="top_span"><a href="javascript:answer_top(<?php echo $this->_var['answer']['id']; ?>)">置顶</a>&nbsp;|</span> <?php endif; ?>
            <?php endif; ?>
            
            <?php if ($this->_var['user']['is_admin'] == 1): ?> <a href="javascript:delete_answer(<?php echo $this->_var['answer']['id']; ?>)">删除</a>&nbsp;|
            
            <?php endif; ?> </div>
            <div class="clear"></div>
        </div>
        
      </div>
      <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
      <div id="answer_list">
      <?php $_from = $this->_var['answer_list']['common_answer']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'answer');if (count($_from)):
    foreach ($_from AS $this->_var['answer']):
?>
      <div class="other_answer_list_other">
        <div class="answer_people"> <img src="<?php echo $this->_var['answer']['avatar_path']; ?>"/> </div>
        <div class="answer_people_right">
          <p><?php echo $this->_var['answer']['content']; ?></p>
          <p><?php echo $this->_var['answer']['username']; ?><span>回答于&nbsp;&nbsp;&nbsp;<?php echo Date::floortime($this->_var['answer']['add_time'],2); ?> </span></p>
          <?php if ($this->_var['answer']['comments_count'] != 0): ?>
          <p style="font-weight:bolder;">- - -共有&nbsp;&nbsp;&nbsp;<?php echo $this->_var['answer']['comments_count']; ?> &nbsp;&nbsp;&nbsp;条评论- - -</p>
          <?php endif; ?>
          <?php if (count ( $this->_var['answer']['comments'] ) > 0): ?>
          <?php $_from = $this->_var['answer']['comments']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'comment');if (count($_from)):
    foreach ($_from AS $this->_var['comment']):
?>
          <p style=" color:#ff6600;"><img src="<?php echo $this->_var['comment']['avatar_path']; ?>"/><?php echo $this->_var['comment']['content']; ?> <span>(<?php echo $this->_var['comment']['add_time']; ?>)by <?php echo $this->_var['comment']['username']; ?>)</span></p>
          <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
          <?php endif; ?>
          <div class="votes" style="float: right;"> <span id="answer_message_<?php echo $this->_var['answer']['id']; ?>"></span> <span id="answer_votes_<?php echo $this->_var['answer']['id']; ?>"> <a href="javascript:add_answer_votes('up',<?php echo $this->_var['answer']['id']; ?> )">有帮助</a><em>(<?php echo $this->_var['answer']['up_votes']; ?>)</em>&nbsp;| <a href="javascript:add_answer_votes('down',<?php echo $this->_var['answer']['id']; ?> )">没帮助</a><em>(<?php echo $this->_var['answer']['down_votes']; ?>)</em>&nbsp;| </span> <a href="javascript:void(0);" id="replay_answer_<?php echo $this->_var['answer']['id']; ?>" class="replay_answer" title="<?php echo $this->_var['answer']['id']; ?>">回复</a><em>(<?php echo $this->_var['answer']['comment_count']; ?>)</em>&nbsp;|
            <?php if ($this->_var['data']['user_id'] == $this->_var['user']['id']): ?>
            <?php if (! count ( $this->_var['top_answer'] ) > 0): ?> <span class="top_span"><a href="javascript:answer_top(<?php echo $this->_var['answer']['id']; ?>)">置顶</a>&nbsp;|</span> <?php endif; ?>
            <?php endif; ?>
            
            <?php if ($this->_var['user']['is_admin'] == 1): ?> <a href="javascript:delete_answer(<?php echo $this->_var['answer']['id']; ?>)">删除</a>&nbsp;|
            
            <?php endif; ?> </div>
        </div>  <div class="clear"></div>
      </div>
    
      <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?> </div></div>
    <div>
      <input type="hidden" id="answer_category_id" value="<?php echo $this->_var['data']['category_id']; ?>"/>
      <input type="hidden" id="answer_parent_id" value="<?php echo $this->_var['data']['id']; ?>"/>
       <table style="width:100%">
          <tr>
            <td width="10%">留&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;言：</td>
            <td>  <textarea id='answer_content' name='content' style="width:80%"></textarea></td>
          </tr>
          <tr>
            <td>验&nbsp;证&nbsp;码：</td>
            <td><input type='text' id='captcha' name='captcha'  class='text'/></td>
          </tr>
            <tr>
            <td></td>
            <td><?php echo $this->_var['captcha']; ?></td>
          </tr>
          <tr>
            <td></td>
            <td align="center"><input type='button' value=' 我要回答 ' id="answer_click" class='rndbutton'/><span class="answer_message"></span></td>
          </tr>
        </table>
     
      <br/>
    </div>
  </div>
  <div class="q2a_detail_right">
    <div class="want_question">
      <p>有什么技术问题吗？</p>
      <div><a href="<?php echo $this->_var['site_url']; ?>question">我要提问</a></div>
    </div>
    <div class="another_questions">
      <div class="another_questions_top"><a href="#">氿上管理员</a>的其它问题<span><a href="<?php echo $this->_var['site_url']; ?>question">全部问题>></a></span></div>
      <ul>
        <?php if (count ( $this->_var['user_related_questions'] ) > 0): ?>
        <?php $_from = $this->_var['user_related_questions']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'related_question');if (count($_from)):
    foreach ($_from AS $this->_var['related_question']):
?>
        <li><img src="<?php echo $this->_var['images_path']; ?>/point.png"/>&nbsp;&nbsp;<a href="<?php echo $this->_var['related_question']['url']; ?>" title="<?php echo $this->_var['related_question']['name']; ?>"><?php echo $this->_var['related_question']['name']; ?></a>
          <p>(<?php echo $this->_var['related_question']['answer_count']; ?>回/<?php echo $this->_var['related_question']['view_count']; ?>阅,<?php echo Date::floortime($this->_var['related_question']['add_time'],2); ?>)</p>
        </li>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
        <?php endif; ?>
      </ul>
    </div>
    <div class="pic_size"><img src="<?php echo $this->_var['images_path']; ?>/right_pic.jpg"/></div>
    <div class="another_questions">
      <div class="another_questions_top">类似问题<span><a href="<?php echo $this->_var['site_url']; ?>question">全部问题>></a></span></div>
      <ul>
        <?php if (count ( $this->_var['category_related_questions'] ) > 0): ?>
        <?php $_from = $this->_var['category_related_questions']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'related_question');if (count($_from)):
    foreach ($_from AS $this->_var['related_question']):
?>
        <li><img src="<?php echo $this->_var['images_path']; ?>/point.png"/>&nbsp;&nbsp;<a href="<?php echo $this->_var['related_question']['url']; ?>" title="<?php echo $this->_var['related_question']['name']; ?>"><?php echo $this->_var['related_question']['name']; ?></a>
          <p>(<?php echo $this->_var['related_question']['answer_count']; ?>回/<?php echo $this->_var['related_question']['view_count']; ?>阅,<?php echo Date::floortime($this->_var['related_question']['add_time'],2); ?>)</p>
        </li>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
        <?php endif; ?>
      </ul>
    </div>
    <div class="pic_size"><img src="<?php echo $this->_var['images_path']; ?>/right_pic_last.jpg"/></div>
  </div>
</div>
<div class="clear"></div>
<div style="display:none">
  <div id="inline" style=" overflow:auto"> 
  <?php if (count ( $this->_var['user'] ) > 0): ?>
    <form action="<?php echo $this->_var['site_url']; ?>comment/add" method="post">
      <input name="question_id" type="hidden" value="<?php echo $this->_var['data']['id']; ?>"/>
      <input type="hidden" id="page" value="<?php echo $this->_var['page_num']; ?>" name="page"/>
      <input class="commont_answer_id" type="hidden" name="parent_id"/>
      <textarea id='commont_content' name='content' style='width:360px;height:160px;'></textarea>
      <input type='submit' value=' 我要回复 '  class='rndbutton commont_click'/>
      <span class="commont_message"></span>
    </form>
    <?php else: ?>
    请先登录,登录请<a href="<?php echo $this->_var['site_url']; ?>user/login">点这里</a> <?php endif; ?> </div>
</div>
<script type="text/javascript" src="<?php echo $this->_var['js_path']; ?>/message.js"></script> 
<script type="text/javascript" src="<?php echo $this->_var['js_path']; ?>/jquery.validate.js"></script> 
<script type="text/javascript" src="<?php echo $this->_var['js_path']; ?>/jquery.validate.js"></script> 
<script type="text/javascript" src="<?php echo $this->_var['js_path']; ?>/fancybox/jquery.fancybox-1.3.1.pack.js"></script> 
<link type="text/css" rel="stylesheet" href="<?php echo $this->_var['js_path']; ?>/fancybox/fancybox.css" />
<script type="text/javascript" src="<?php echo $this->_var['js_path']; ?>/jnotify/jNotify.jquery.js"></script> 
<link type="text/css" rel="stylesheet" href="<?php echo $this->_var['js_path']; ?>/jnotify/jNotify.jquery.css" />
<script>           
function add_votes(act){  
  id = <?php echo $this->_var['data']['id']; ?>;
  $.ajax({
	  type: 'post',
	  url: '<?php echo $this->_var['site_url']; ?>q2a_ajax/get_votes',
	  data: 'id='+id+'&act='+act,
	  dataType: 'json',
	  beforeSend:function(XMLHttpRequest){
		  $("#msg").show().html("操作中... ...");
	   },
	  success: function(data){
		  if(data.message != ''){
			  var message = "<font color=\"red\">"+data.message+"</font>";
			  $("#msg").show().html(message).fadeOut(2000);
			  $('#support_num').text(data.up_votes);
		  	  $('#step_num').text(data.down_votes);
		  }
	  }
  });
}


/* 收藏商品 */
function collect_q2a(id)
{
 
	var title = $('#q2a_name').text();
	var url = '<?php echo $this->_var['site_url']; ?>ajax/add_collect/';
	$.post(url, {'id':id,'type':'q2a','title':title}, function(data){
		$("#msg").show().html(data).fadeOut(2000);
	});
}


$(function(){
	$('.replay_answer').live('click',function(){
		$('.commont_answer_id').val($(this).attr('title'));
		$.fancybox({
			'content': $('#inline').html()
		})
	});
	
	 $.ajax({
		type: 'post',
		url: '<?php echo $this->_var['site_url']; ?>q2a_ajax/get_votes',
		data: 'id='+<?php echo $this->_var['data']['id']; ?>,
		dataType: 'json',
		beforeSend:function(XMLHttpRequest){
		  $("#msg").show().html("操作中... ...");
	   },
		success: function(data){
			$('#support_num').text(data.up_votes);
			$('#step_num').text(data.down_votes);
			$("#msg").show().html(data.message).fadeOut(2000);
		}
	});
	
	
	
	 $('#answer_click').click(function(){
		var answer_content = $('#answer_content').val();
		var parent_id = $('#answer_parent_id').val();
		var captcha = $('#captcha').val();
		var answer_category_id = $('#answer_category_id').val();
		if(answer_content ==''){
			$('.answer_message').show().html('<font color=red>评论内容不能为空</font>').fadeOut(3000);
		} else if(captcha == ''){
			$('.answer_message').show().html('<font color=red>验证码不能为空</font>').fadeOut(3000);
		}else{
			$.ajax({
				type: 'post',
				url: '<?php echo $this->_var['site_url']; ?>q2a_ajax/add_answer',
				cache: false,
				data: 'content='+answer_content+'&parent_id='+parent_id+'&category_id='+answer_category_id+'&catpcha='+captcha,
				dataType: 'html',
				beforeSend:function(XMLHttpRequest){
					$(".answer_message").show().html("操作中... ...");
				},
				success: function(data){
					document.getElementById('captcha_change').src = '<?php echo $this->_var['site_url']; ?>captcha/default?r='+Math.random();
					if(data == 0){
						$('.answer_message').show().html('<font color=red>验证码错误</font>').fadeOut(3000);
					}else{
						$("#answer_list").append(data);
						$('.answer_message').show().html('<font color=blue>添加成功</font>').fadeOut(3000);
					}
				}
			});
		}
	});
});

</script> 
 
<?php echo $this->fetch('footer.html'); ?>
</body>
</html>
